package com.oa.co.controller;

import com.oa.co.common.PageVo;
import com.oa.co.common.R;
import com.oa.co.pojo.Attendance;
import com.oa.co.service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@CrossOrigin("*")
@RequestMapping("/api/atte")
@RestController
public class AttendanceContoller {

    @Autowired
    private AttendanceService attendanceService;

    @RequestMapping("/atteInfo")
    public PageVo<Attendance> atteInfo(@RequestParam Map<String, Object> params){

        return attendanceService.showAtte(params);
    }

    @RequestMapping("/atteAdd")
    public R addAttendance(@RequestBody Attendance attendance){
        System.out.println(attendance);
        int result = attendanceService.addAttendance(attendance);
        if(result==1){

            return R.ok();
        }
        return R.error();
    }

    @RequestMapping("atteDle")
    public R deleteAttendance(Integer id){
        int result = attendanceService.deleteAttendance(id);

        if(result==1){
            return R.ok().message("删除成功");
        }
        return R.error().message("删除失败");
    }

}
